<?php include('php/authenticatephastregex.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
  <head>
    <title>Phastregex. in-silico chip-seq</title>
    <meta http-equiv="Content-Type" content ="text/html; charset=utf-8">
    <link rel="stylesheet" href="phastregexstylejw.css" type="text/css">
    <?php include('php/jasonweirather.php'); ?>
  </head>
  <body>
    <?php include('php/logoline.php'); ?>
    <div id = "hit_results_block">
    <?php
      $filename = $_POST["local_file_name"];
      $feature_name = $_POST["feature_name"];
      $table_name = $_POST["table_name"];
      $filter = $_POST["filter"];
      $max_distance_outside_feature = $_POST["max_distance_outside_feature"];
      $max_distance_from_midpoint = $_POST["max_distance_from_midpoint"];     
      echo("Process $filename on feature $feature_name from database $table_name with filtering set to $filter<br>");
      ### check to see if it is in the database and completed already.
      $_SESSION['basename'] = NULL;
      include("php/filehandles.php");
      $annotatedfile = "$basename" . "_annotated.txt";
      # we need to generate the conservation file
        $command = "cat $workingdirectory/$filename | $phastregex2path/add_and_print_generic_feature.pl $table_name $feature_name $filter $max_distance_outside_feature $max_distance_from_midpoint > $workingdirectory/$annotatedfile";
        echo "Executing: $command<br>\n";
        flush();
        sleep(1);
        $lines = `$command`;
       #$_SESSION['conserved_file_generated'] = 0; #for testing
      echo("Annotated file is availible for download:<br>");
      echo("<a href = \"$working_address/$annotatedfile\">$working_address/$annotatedfile</a><br>");
     echo('<form enctype="multipart/form-data" action="annotate.php" method="post">Annotate and or filter this file further:<br>');
     echo("<input type=\"hidden\" name=\"local_file_name\" value=\"$annotatedfile\"/>");
     echo('<input type="submit" value="Annotate and/or filter more"/>');
     echo('</form><br>');
     echo('<form enctype="multipart/form-data" action="genename.php" method="post">Generate a file with per-gene results:<br>');
     echo("<input type=\"hidden\" name=\"local_file_name\" value=\"$annotatedfile\"/>");
     echo('<input type="submit" value="Per-gene results"/>');
     echo('</form>');

    # print the conserved file here.

    ?>
    <?php include('php/lastline.php'); ?>
  </body>
</html>
